Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding support for leading dot. adding use of prototypical inheritance for Stack's substitutions and partials #237

Closed
wants to merge 2 commits into from

Conversation

shYkiSto
Copy link

There was new feature proposed which is in line with the current spec(which isn't updating for years :() here: mustache/spec#52

It's been implemented in some of the Mustache implementations already and is backward compatible. It should allow us avoid issues when some key is missing in top context and engine is looking for that variable in parent contexts.

fedarovs added 2 commits December 17, 2015 16:16
…partials. This should correct issue when one substitution is overriding others used for the same partial, when used inside another partial(multi level inheritance)
@shYkiSto shYkiSto changed the title adding support for leading dot. see https://github.com/mustache/spec/… adding support for leading dot. adding use of prototypical inheritance for Stack's substitutions and partials May 13, 2016
@shYkiSto
Copy link
Author

Fixed an issue with substitutions when one overrides any other substitutions used for the same partial template during multi level inheritance(in other words all that happening inside other partial template).

Here's the test sample:

{{!subPartial.mustache}}
Haloha! {{$replace}}replace me{{/replace}}
{{!partial.mustache}}
{{<subPartial}}
    {{$replace}}removed1{{/replace}}
{{/subPartial}}
{{<subPartial}}
    {{$replace}}removed2{{/replace}}
{{/subPartial}}
{{!main.mustache}}
{{>partial}}

Without the fix it renders:

Haloha! removed1 Haloha! removed1

When second replacement should be removed2.

The fix is that the stackSubs & stackPartials are updated with prototypical inheritance. So one partial doesn't affect others. And instead just inherits all the information from the parent.

@shYkiSto
Copy link
Author

Can split up my work into 2 separated PR.. but not sure if they're going to be ever accepted...

@CLAassistant
Copy link

CLAassistant commented Jul 18, 2019

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


fedarovs seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@shYkiSto shYkiSto closed this Dec 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants